package org.darkforest.common.services.impl;

import org.darkforest.common.services.StoreGradeService;
import org.darkforest.dao.mapper.StoreGradeMapper;
import org.darkforest.model.StoreGrade;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2015/12/16.
 */
@Service
public class StoreGradeServiceImpl implements StoreGradeService {

    @Autowired
    private StoreGradeMapper storeGradeMapper;

    @Override
    public int deleteByPrimaryKey(Integer sgId) {
        return storeGradeMapper.deleteByPrimaryKey(sgId);
    }

    @Override
    public int insert(StoreGrade record) {
        return storeGradeMapper.insert(record);
    }

    @Override
    public int insertSelective(StoreGrade record) {
        return storeGradeMapper.insertSelective(record);
    }

    @Override
    public StoreGrade selectByPrimaryKey(Integer sgId) {
        return storeGradeMapper.selectByPrimaryKey(sgId);
    }

    @Override
    public int updateByPrimaryKeySelective(StoreGrade record) {
        return storeGradeMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKeyWithBLOBs(StoreGrade record) {
        return storeGradeMapper.updateByPrimaryKeyWithBLOBs(record);
    }

    @Override
    public int updateByPrimaryKey(StoreGrade record) {
        return storeGradeMapper.updateByPrimaryKey(record);
    }

    /**
     * 根据店铺条件查询店铺列表
     *
     * @param storeGrade
     * @return
     */
    @Override
    public List<StoreGrade> selectStoreGradeByCondition(StoreGrade storeGrade) {
        return storeGradeMapper.selectStoreGradeByCondition(storeGrade);
    }

    /**
     * 批量删除店铺等级
     *
     * @param ids
     * @return
     */
    @Override
    public int delStoreGradeBatch(String[] ids) {
        List<String> list = new ArrayList<String>();
        for(String id:ids){
            list.add(id);
        }

        return storeGradeMapper.delStoreGradeBatch(list);
    }

    /**
     * 编辑店铺等级时校验数据
     *
     * @param storeGrade
     * @return
     */
    @Override
    public List<StoreGrade> checkStoreGradeNameOrSortForModify(StoreGrade storeGrade) {
        return storeGradeMapper.checkStoreGradeNameOrSortForModify(storeGrade);
    }
}
